package com.peza.bikelog.common.util;

import com.peza.bikelog.common.domain.garmin.AbstractSourceT;
import com.peza.bikelog.common.domain.garmin.ActivityListT;
import com.peza.bikelog.common.domain.garmin.ActivityT;
import com.peza.bikelog.common.domain.garmin.ApplicationT;
import com.peza.bikelog.common.domain.garmin.BuildT;
import com.peza.bikelog.common.domain.garmin.BuildTypeT;
import com.peza.bikelog.common.domain.garmin.CourseFolderT;
import com.peza.bikelog.common.domain.garmin.CourseListT;
import com.peza.bikelog.common.domain.garmin.CoursesT;
import com.peza.bikelog.common.domain.garmin.ExtensionsT;
import com.peza.bikelog.common.domain.garmin.FoldersT;
import com.peza.bikelog.common.domain.garmin.TrainingCenterDatabaseT;
import com.peza.bikelog.common.domain.garmin.VersionT;

public class TrainingCenterFactory {

	private static TrainingCenterFactory instance;
	
	
	private TrainingCenterFactory(){
		
	}
	
	public static TrainingCenterFactory getInstance(){
		if (instance == null){
			instance = new TrainingCenterFactory();
		}
		return instance;
	}

	public TrainingCenterDatabaseT createActivity(ActivityT activity, AbstractSourceT author){
		TrainingCenterDatabaseT tcdb = new TrainingCenterDatabaseT();
		ActivityListT activities = new ActivityListT();
		activities.getActivity().add(activity);	
		tcdb.setActivities(activities);
		tcdb.setAuthor(author);
			
		return tcdb;
	}

	
	public TrainingCenterDatabaseT createBlank(){
		TrainingCenterDatabaseT tcdb = new TrainingCenterDatabaseT();
		ActivityListT activities = new ActivityListT();
		ApplicationT author = new ApplicationT();
		BuildT build = new BuildT();
		BuildTypeT buildType = BuildTypeT.RELEASE;
		VersionT version = new VersionT();
		CourseListT courseList = new CourseListT();
		ExtensionsT extensions = new ExtensionsT();
		FoldersT folders = new FoldersT();
		CoursesT courses = new CoursesT();
		CourseFolderT courseFolder = new CourseFolderT();
		
		courseFolder.setExtensions(extensions);
		
		courses.setCourseFolder(courseFolder);
		
		folders.setCourses(courses);
		//folders.setHistory(value);
		//folders.setWorkouts(value);
		
		build.setType(buildType);
		build.setVersion(version);
		
		author.setBuild(build);
	
		tcdb.setActivities(activities);
		tcdb.setAuthor(author);
		tcdb.setCourses(courseList);
		tcdb.setExtensions(extensions);
		tcdb.setFolders(folders);
		//tcdb.setWorkouts(value);
		
		return tcdb;
	}
	
}
